/*-
 * Copyright (c) 2006, 2007 FTS Team
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 4. Neither the name of the FTS Team nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *      ConfigTest.cpp
 *
 * $FTS$
 */
#include <stdio.h>
#include <string.h>

#include <IRConfig.hpp>

using namespace FTSS;

int main(int argc, char ** argv)
{

	IRConfig oConfig(1);

	oConfig.AddKey("SomeNumKey",    "123");
	oConfig.AddKey("SomeFloatKey",  "0.001");
	oConfig.AddKey("SomeStringKey", "Test passed");

	oConfig.AddKey("SomeFlagKey1", "On");
	oConfig.AddKey("SomeFlagKey2", "on");
	oConfig.AddKey("SomeFlagKey3", "true");
	oConfig.AddKey("SomeFlagKey4", "Off");
	oConfig.AddKey("SomeFlagKey5", "Yes");
	oConfig.AddKey("SomeFlagKey6", "No");

	fprintf(stdout, "Num INT_32:  %d\n",   oConfig.GetInt32("SomeNumKey"));
	fprintf(stdout, "Num INT_64:  %lu\n",  long(oConfig.GetInt64("SomeNumKey")));
	fprintf(stdout, "Num W_FLOAT: %f\n",   oConfig.GetFloat("SomeNumKey"));
	fprintf(stdout, "Num String:  %s\n\n", oConfig.GetString("SomeNumKey").c_str());

	fprintf(stdout, "Float INT_32:  %d\n",   oConfig.GetInt32("SomeFloatKey"));
	fprintf(stdout, "Float INT_64:  %lu\n",  long(oConfig.GetInt64("SomeFloatKey")));
	fprintf(stdout, "Float W_FLOAT: %f\n",   oConfig.GetFloat("SomeFloatKey"));
	fprintf(stdout, "Float String:  %s\n\n", oConfig.GetString("SomeFloatKey").c_str());

	fprintf(stdout, "String INT_32:  %d\n",   oConfig.GetInt32("SomeStringKey"));
	fprintf(stdout, "String INT_64:  %lu\n",  long(oConfig.GetInt64("SomeStringKey")));
	fprintf(stdout, "String W_FLOAT: %f\n",   oConfig.GetFloat("SomeStringKey"));
	fprintf(stdout, "String String:  %s\n\n", oConfig.GetString("SomeStringKey").c_str());

	fprintf(stdout, "N/A INT_32:  %d\n",   oConfig.GetInt32("SomeNAKey", 1));
	fprintf(stdout, "N/A INT_64:  %lu\n",  long(oConfig.GetInt64("SomeNAKey", 2)));
	fprintf(stdout, "N/A W_FLOAT: %f\n",   oConfig.GetFloat("SomeNAKey", 3.14));
	fprintf(stdout, "N/A String:  %s\n\n", oConfig.GetString("SomeNAKey", "Non-existent").c_str());

	fprintf(stdout, "Flag 1: %c\n",   oConfig.GetFlag("SomeFlagKey1", 1) ? 't':'f');
	fprintf(stdout, "Flag 2: %c\n",   oConfig.GetFlag("SomeFlagKey2", 1) ? 't':'f');
	fprintf(stdout, "Flag 3: %c\n",   oConfig.GetFlag("SomeFlagKey3", 1) ? 't':'f');
	fprintf(stdout, "Flag 4: %c\n",   oConfig.GetFlag("SomeFlagKey4", 1) ? 't':'f');
	fprintf(stdout, "Flag 5: %c\n",   oConfig.GetFlag("SomeFlagKey5", 1) ? 't':'f');
	fprintf(stdout, "Flag 6: %c\n",   oConfig.GetFlag("SomeFlagKey6", 1) ? 't':'f');
	fprintf(stdout, "Flag 7: %c\n\n", oConfig.GetFlag("SomeFlagKey7", 1) ? 't':'f');


	fprintf(stdout, "Done.\n");

	// make valgrind happy
	fclose(stdin);
	fclose(stdout);
	fclose(stderr);
}
// End.
